﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace JMT.Data.Serializer
{
    public class JRelationSerializer : JModelSerializer
    {
        protected override void OnSerialize(XElement xElement, JModel jModel)
        {
            JRelation jRelation = jModel as JRelation;
            xElement.Add(new XAttribute("fromid", jRelation.FromId));
            xElement.Add(new XAttribute("toid", jRelation.ToId));
        }

        protected override void OnDeserialize(XElement xElement, JModel jModel)
        {
            JRelation jRelation = jModel as JRelation;
            jRelation.FromId = new Guid(xElement.Attribute("fromid").Value);
            jRelation.ToId = new Guid(xElement.Attribute("toid").Value);
        }
    }
}